FROM atd-registry.sp.baishan.com/new-orchsym/node:18.16.1 AS web

WORKDIR /web
COPY ./web/ .

RUN pnpm i && pnpm build:prod


FROM atd-registry.sp.baishan.com/new-orchsym/golang:1.20.4.1 as builder

WORKDIR /server
COPY ./backend/ .
COPY --from=web /web/dist/ ./vue/dist/

RUN go env -w GO111MODULE=on \
    && go env -w GOPROXY=https://goproxy.cn,direct \
    && go env -w CGO_ENABLED=0 \
    && go env \
    && go-bindata-assetfs -o vue/vue.go -pkg=vue vue/dist/... \
    && go generate \
    && go build -o drawer .

FROM atd-registry.sp.baishan.com/new-orchsym/alpine:3.18.3

LABEL MAINTAINER="jianzhao.lv@baishan.com"

# 安装时区数据
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.11/main\nhttp://mirrors.aliyun.com/alpine/v3.11/community" > /etc/apk/repositories \
    && apk add -U tzdata bash vim\
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

WORKDIR /opt/drawer

COPY --from=builder /server/drawer ./
COPY --from=builder /server/docker/config_tpl.yaml /tmp/
COPY --from=builder /server/docker/docker-entrypoint.sh /entrypoint.sh

EXPOSE 5558

ENTRYPOINT ["bash", "/entrypoint.sh"]

